<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>table模块快速使用</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all">

    <script src="/static/layui/layui.js"></script>
    <script src="/static/js/jquery.min.js"></script>
</head>
<body style="height: 100%">

<form class="layui-form" action="" autocomplete="new-password">
    <input type="hidden" name="sdId" value="${model.sdId}">

    <div class="layui-form-item" >
        <label class="layui-form-label">FirstName</label>
        <div class="layui-input-block" style="padding-left: 10px;padding-right: 10px">
            <input type="text" name="firstName"  value="${model.firstName}"  readonly="readonly" lay-verify="required"   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item" >
        <label class="layui-form-label">LastName</label>
        <div class="layui-input-block" style="padding-left: 10px;padding-right: 10px">
            <input type="text" name="lastName"  value="${model.lastName}"  readonly="readonly" lay-verify="required"   class="layui-input">
        </div>
    </div>


    <div class="layui-form-item" >
        <label class="layui-form-label">Address</label>
        <div class="layui-input-block" style="padding-left: 10px;padding-right: 10px">
            <input type="text" name="address"  value="${model.address}"  readonly="readonly" lay-verify="required"   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item" >
        <label class="layui-form-label">Address2</label>
        <div class="layui-input-block" style="padding-left: 10px;padding-right: 10px">
            <input type="text" name="address2"  value="${model.address2}"  readonly="readonly" lay-verify="required"   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item" >
        <label class="layui-form-label">CountryName</label>
        <div class="layui-input-block" style="padding-left: 10px;padding-right: 10px">
            <input type="text" name="countryName"  value="${model.countryName}"  readonly="readonly" lay-verify="required"   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item" >
        <label class="layui-form-label">TownCity</label>
        <div class="layui-input-block" style="padding-left: 10px;padding-right: 10px">
            <input type="text" name="townCity"  value="${model.townCity}"  readonly="readonly" lay-verify="required"   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" >
        <label class="layui-form-label">StateCountry</label>
        <div class="layui-input-block" style="padding-left: 10px;padding-right: 10px">
            <input type="text" name="stateCountry"  value="${model.stateCountry}"  readonly="readonly" lay-verify="required"   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" >
        <label class="layui-form-label">PostcodeZip</label>
        <div class="layui-input-block" style="padding-left: 10px;padding-right: 10px">
            <input type="text" name="postcodeZip"  value="${model.postcodeZip}"  readonly="readonly" lay-verify="required"   class="layui-input">
        </div>
    </div>

</form>

<script>
    layui.use(['upload','jquery','form','util'], function(){
        var $ = layui.jquery
            ,upload = layui.upload
            ,form = layui.form;

        //图片上传
        var uploadInst = upload.render({
            elem: '#uploadImg'
            , size: 1024 * 20 //限制文件大小，单位 KB
            , multiple: true
            , url: '/uploadFiles/uploadManyImage'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $("#img").css('display', 'block').attr('src', result);
                    //加载层
                    // layer.load(1);
                });
            }
            , done: function (res) {
                //200成功 500失败
                if (res.code == 200) {
                    layer.closeAll('loading');
                    $("#thumb").val(res.urlList);
                } else {
                    return layer.msg('Upload failed');
                }
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">Upload failed</span> <a class="layui-btn layui-btn-xs demo-reload">Retry</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });

        //监听提交
        form.on('submit(commit)', function(data){
            var typeStatus=$("#typeStatus").val();
            if (typeStatus==-1){
                layer.msg("Please select the category state");
                return false;
            }

            $.ajax({
                url : '/manage/goodsType/update',
                type : 'post',
                dataType : 'json',
                data : data.field,
                success : function (data) {
                    if (data.code==200){
                        layer.msg(data.msg,{icon: 1, time: 500},function () {
                            layer.close();
                            window.parent.location.reload();
                        });
                    }else{
                        layer.msg(data.msg,{icon: 2, time: 1000});
                    }
                }
            })
            return false;
        });

    });
</script>

</body>
</html>
